<?php

/**
 * Impress - Open source digital signage
 *
 * @link http://digitalsignage.tk
 * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
 *
 * @category Impress
 * @package Impress
 */

/**
 * This class provides access to input.
 *
 * @package Impress
 * @subpackage Core
 */

class ADS_Input{
    /**
     * Method extracts variable from GET request.
     * 
     * @param type $name
     * @param type $default
     * @return type 
     */
    public static function getVar($name, $default = null){
        return isset($_GET[$name])?$_GET[$name]:$default;
    }
    /**
     * Method extracts variable from POST request.
     * 
     * @param type $name
     * @param type $default
     * @return type 
     */
    public static function postVar($name,$default = null){
        $indexes = explode('.', $name);
        //extract value from array
        if(count($indexes) > 1){
            $ret = $_POST;
            foreach($indexes as $index){
                if(!isset($ret[$index])){
                    return $default;
                }
                $ret = $ret[$index];
            }
            return $ret;
        }
        //extract value from variable
        return isset($_POST[$name])?$_POST[$name]:$default;
    }
}
